#!/usr/bin/env python

import resource.string.karin

from .._console import Console

class Sender(App):

    def run(self):
        self.greeting(resource.string.karin)
        
        self.send()
        
        self.warning('\nGood bye ^_^v\n')
        
    def send(self):
        subject = 'Karin Mail Test'
        message = 'Karin Mail Test'
        destination = self._args.destination

        s = 'Sending mail to %s via Telkom... '
        self.progress(s % destination)
        mail = components.Mail(subject, message, destination)
        try:
            mail.sendTelkom()
            self.success('OK ^_^v\n')
        except:
            self.fail('Error >_<\n')

        s = 'Sending mail to %s via Gmail... '
        self.progress(s % destination)
        mail = components.Mail(subject, message, destination)
        try:
            mail.sendGmail()
            self.success('OK ^_^v\n')
        except:
            self.fail('Error >_<\n')
